package com.five.service.Impl;

import com.five.dao.ClubActRegDao;
import com.five.pojo.ClubActReg;
import com.five.pojo.PageBean;
import com.five.service.ClubActRegService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClubActRegServiceImpl implements ClubActRegService {

    @Autowired
    private ClubActRegDao clubActRegDao;


    @Override
    public PageBean page(Integer pageNum, Integer pageSize, String actName) {
        PageHelper.startPage(pageNum , pageSize);
        List<ClubActReg> clubActRegList = clubActRegDao.list(actName);
        Page<ClubActReg> p = (Page<ClubActReg>) clubActRegList;
        PageBean pageBean = new PageBean(p.getTotal() , p.getResult());
        return pageBean;
    }

    @Override
    public void addPeople(ClubActReg clubActReg) {
        clubActReg.setStatus(0);
        clubActRegDao.addPeople(clubActReg);
    }

    @Override
    public List<ClubActReg> getByActClub(String actClub) {
        List<ClubActReg> clubActRegList = clubActRegDao.getByActClub(actClub);
        return clubActRegList;
    }

    @Override
    public void updateStatus(Integer status, Integer id) {
        clubActRegDao.updataStatus(status , id);
    }

    @Override
    public void deleteById(Integer id) {
        clubActRegDao.deleteById(id);
    }
}
